package com.wpi.iCoach;

import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ImageButton;

/**
 * This class is to show the user what services this App provides.
 * @author Kenneth J. Loomis (kjloomis)
 * @version June 2012
 */
public class MainMenu extends Activity implements View.OnClickListener {
    /**
     * These are buttons and imageButtons which would be 
     * displayed on the screen for users to use. 
     */
	private ImageButton benefits;
	private Button custom;
	private ImageButton education;
	private ImageButton health;
	private ImageButton housing;
	private Button setCustom;
	
	/** Called when the activity is first created. */
    
	/**
	 * This method would be called when this activity is first created.
	 * It would first load its UI component from the main.xml.
	 * In main.xml, there are 4 ImageButtons and 2 Buttons. All clickListener would be set.
	 * @param saveInstanceState
	 */
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        benefits = ( ImageButton ) this.findViewById( R.id.btnBenefits );
        custom = ( Button ) this.findViewById( R.id.btnCustom );
        education = ( ImageButton ) this.findViewById( R.id.btnEducation );
        health = ( ImageButton ) this.findViewById( R.id.btnHealth );
        housing = ( ImageButton ) this.findViewById( R.id.btnHousing );
        setCustom = ( Button ) this.findViewById( R.id.btnSetCustom );
        
        benefits.setOnClickListener( this );
        custom.setOnClickListener( this );
        education.setOnClickListener( this );
        health.setOnClickListener( this );
        housing.setOnClickListener( this );
        setCustom.setOnClickListener( this );
         
    }

	/**
	 * This method handles what appropriate activity would be started 
	 * when any button on the screen is clicked.  
	 * @param v
	 * @throws e
	 */
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		Intent openApp = null;
		
		try
		{
			if ( v == benefits )
			{
				openApp = new Intent ( "com.wpi.iCoach.FINDSAVED" );
			}
			if ( v == custom )
			{
				openApp = new Intent ( "com.wpi.iCoach.FINDSAVED" );
			}
			if ( v == education )
			{
				openApp = new Intent ( "com.wpi.iCoach.FINDSAVED" );
			}
			if ( v == health )
			{
				openApp = new Intent ( "com.wpi.iCoach.FINDSAVED" );
			}
			if ( v == housing )
			{
				openApp = new Intent ( "com.wpi.iCoach.FINDSAVED" );
			}
			if ( v == setCustom )
			{
				openApp = new Intent ( "com.wpi.iCoach.SAVELOCATION" );
			}
			if ( openApp != null )
				startActivity ( openApp );
		}
		catch ( Exception e )
		{
			e.printStackTrace ( );
		}
	}
}
